package com.own.business.question.entity.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.own.business.question.common.base.ReplyEnvironment;
import com.own.business.question.common.handler.ReplyEnvironmentHandler;
import com.own.component.common.base.entity.po.BasePo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * PracticeMistake
 *
 * @author 陈学礼 （你是一段成熟的代码，要学会自己改bug）
 * @version 4.0.0
 * @date 2021/05/14 15:49:28
 * @since 4.0.0
 */
@Schema(description = "练习错题表" + ConstantBeanSuffix.PO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "practice_mistake", autoResultMap = true)
public class PracticeMistake extends BasePo {

    @Schema(description = "用户id")
    private Long fkUserId;

    @Schema(description = "流水id")
    private Long fkHistoryId;

    @Schema(description = "题目id")
    private Long fkQuestionId;

    @Schema(description = "用户答案")
    private String answer;

    @Schema(description = "作答环境")
    @TableField(typeHandler = ReplyEnvironmentHandler.class)
    private ReplyEnvironment replyEnvironment;

    @Schema(description = "标记状态 0=未记住 1=已记住")
    private Integer status;

    public PracticeMistake(PracticeHistory history) {
        this.fkHistoryId = history.getId();
        this.fkUserId = history.getFkUserId();
        this.fkQuestionId = history.getFkQuestionId();
        this.answer = history.getAnswer();
        this.replyEnvironment = history.getReplyEnvironment();
        this.status = 0;
    }

}
